import Vue from 'vue'
import App from './App.vue'
import router from './router'

import { ActionSheet, Dialog, Field, List, Tab, Tabs, Toast, Uploader, ImagePreview, ShareSheet } from 'vant';
Vue.use(ShareSheet)
Vue.use(Tabs)
Vue.use(Tab)
Vue.use(List)
Vue.use(Uploader)
Vue.use(Dialog)
Vue.use(Field)
Vue.use(ActionSheet)
Vue.use(Toast)
Vue.use(ImagePreview)
import 'vant/lib/share-sheet/style'
import 'vant/lib/tab/style'
import 'vant/lib/tabs/style'
import 'vant/lib/list/style'
import 'vant/lib/uploader/style'
import 'vant/lib/dialog/style'
import 'vant/lib/field/style'
import 'vant/lib/action-sheet/style'
import 'vant/lib/toast/style'
import 'vant/lib/image-preview/style'

Vue.filter('flxImgUrl', (oldUrl) => {
  if (oldUrl.indexOf("http") != -1) {
    return oldUrl;
  } else {
    return axios.defaults.baseURL + oldUrl;
  }
})

Vue.directive("focus", {
  inserted(el) {
    el.focus();
  }
});

import axios from "./utils/axios"
Vue.prototype.$axios = axios;

Vue.config.productionTip = false

import Vuex from 'vuex'
Vue.use(Vuex)

// 初始化vuex对象
const store = new Vuex.Store({
  state: {
    // 管理数据
    count: 19
  },
  mutations: {
    // 方法里参数 第一个参数是当前store的state属性
    // payload 载荷 运输参数 调用mutaiions的时候 可以传递参数 传递载荷
    addCount(state, payload) {
      state.count += payload
    }
  }
})

new Vue({
  router,
  store,
  render: function (h) { return h(App) }
}).$mount('#app')
